import 'dart:io';

import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:flutter_base_plugin/flutter_base_plugin.dart';
import 'package:flutter_base_plugin_example/models/home_product_model.dart';
import 'package:flutter_base_plugin_example/page/home/home_banner.dart';
import 'package:flutter_base_plugin_example/page/home/home_nav_bar.dart';
import 'package:flutter_base_plugin_example/page/home/home_news_bulletin.dart';
import 'package:pull_to_refresh/pull_to_refresh.dart';
import 'home_goods_list.dart';
import 'vm/home_view_model.dart';

class HomePage extends StatefulWidget {
  @override
  State<StatefulWidget> createState() {
    // TODO: implement createState
    return _homePageState();
  }
}

class _homePageState extends BaseProviderState<HomeViewModel, HomePage> {
  @override
  void buildCreate() {
    // TODO: implement buildCreate
    setAppBarTitle("title");
    if (Platform.isAndroid) {
      // CommonUtils.showToast("android");
      bottomVertical = 56;
    } else {
      // CommonUtils.showToast("ios");
      bottomVertical = 92;
    }
  }

  @override
  Widget buildWidget(HomeViewModel viewModel, BuildContext context) {
    // TODO: implement buildWidget

    return ListView(
      padding: EdgeInsets.all(0),
      children: <Widget>[
        HomeBanner(),
        HomeNavBar(),
        HomeNewsBulletin(),
        HomeGoodsList(),
        // HomeClassify(model.classifyList),
        // HomeGoodsList(model.goodsList)
      ],
    );
  }

  @override
  buildViewModel() {
    // TODO: implement buildViewModel
    return HomeViewModel();
  }

  @override
  Widget? buildBaseAppBar() {
    return Container(
      height: getAppBarHeight() + getTopBarHeight(),
      width: double.infinity,
      decoration: const BoxDecoration(
        gradient: LinearGradient(
            begin: Alignment.centerLeft,
            end: Alignment.centerRight,
            colors: [Colors.lightBlue, Colors.red]),
      ),
    );
  }
}
